package com.chaos.framework.model.dto.result.data;

import com.chaos.framework.model.dto.result.Result;
import com.chaos.framework.model.enums.ResultEnum;
import lombok.*;
import lombok.experimental.Accessors;

/**
 * @author Jacky
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class BooleanResult extends Result {

    private Boolean data;

    public BooleanResult(ResultEnum re, Boolean data) {
        this.setCode(re.getCode());
        this.setMsg(re.getDefaultMsg());
        this.setData(data);
    }

    public BooleanResult(Integer code, String msg, Boolean data) {
        this.setCode(code);
        this.setMsg(msg);
        this.setData(data);
    }

    public static BooleanResult ok(Boolean data) {
        return new BooleanResult(ResultEnum.OK.getCode(), "success", data);
    }


    public static BooleanResult error(ResultEnum resultEnum) {
        return new BooleanResult(resultEnum.getCode(), resultEnum.getDefaultMsg(), null);
    }

    public static BooleanResult error(Integer errorCode, String msg) {
        return new BooleanResult(errorCode, msg, null);
    }

    public static BooleanResult error(Integer errorCode, String msg, Boolean data) {
        return new BooleanResult(errorCode, msg, data);
    }


}
